<template>
    <div class="wrapper">
      <swiper :options="swiperOption" v-if="list.length">
        <!-- slides -->
        <swiper-slide v-for="item in list" :key="item.id">
          <img class="swiper-img" :src="item.imgUrl" alt="">
        </swiper-slide>
        <!-- Optional controls -->
        <div class="swiper-pagination"  slot="pagination"></div>
      </swiper>
    </div>
</template>

<script>
export default {
  name: 'HomeSwiper',
  props: {
    list: Array
  },
  data () {
    return {
      // 引用了vue-awesome-swiper 轮播插件
      swiperOption: {
        pagination: '.swiper-pagination',
        loop: true, // 循环模式
        autoplay: 1500, // 自动播放时间
        autoplayDisableOnInteraction: true, // 用户操作swiper之后，是否禁止autoplay
        observer: true, // 修改swiper自己或子元素时，自动初始化swiper
        observeParents: true // 修改swiper的父元素时，自动初始化swiper
      }
    }
  }
}
</script>

<style scoped>
  .wrapper >>> .swiper-pagination-bullet-active{
    background: #ffffff;
  }
  .wrapper{
    overflow: hidden;
    width: 100%;
    height: 0;
    padding-bottom: 30.53%;
  }
  .swiper-img{
    width: 100%;
  }
</style>
